package com.td.module.produce.dal.mysql.husbandry;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.produce.controller.admin.husbandry.vo.HusbandryExportReqVO;
import com.td.module.produce.controller.admin.husbandry.vo.HusbandryPageReqVO;
import com.td.module.produce.dal.dataobject.husbandry.HusbandryDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 生产管理农事 Mapper
 *
 * @author 吴佰强
 */
@Mapper
public interface HusbandryMapper extends BaseMapperX<HusbandryDO> {

    default PageResult<HusbandryDO> selectPage(HusbandryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HusbandryDO>()
                .eqIfPresent(HusbandryDO::getHusbandryEvents, reqVO.getHusbandryEvents())
                .eqIfPresent(HusbandryDO::getInfoId, reqVO.getInfoId())
                .betweenIfPresent(HusbandryDO::getPlanTime, reqVO.getPlanTime())
                .eqIfPresent(HusbandryDO::getExecuteStatus, reqVO.getExecuteStatus())
                .eqIfPresent(HusbandryDO::getMemberId, reqVO.getMemberId())
                .betweenIfPresent(HusbandryDO::getExecuteTime, reqVO.getExecuteTime())
                .eqIfPresent(HusbandryDO::getTake, reqVO.getTake())
                .eqIfPresent(HusbandryDO::getHusbandryImg, reqVO.getHusbandryImg())
                .betweenIfPresent(HusbandryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HusbandryDO::getId));
    }

    default List<HusbandryDO> selectList(HusbandryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<HusbandryDO>()
                .eqIfPresent(HusbandryDO::getHusbandryEvents, reqVO.getHusbandryEvents())
                .eqIfPresent(HusbandryDO::getInfoId, reqVO.getInfoId())
                .betweenIfPresent(HusbandryDO::getPlanTime, reqVO.getPlanTime())
                .eqIfPresent(HusbandryDO::getExecuteStatus, reqVO.getExecuteStatus())
                .eqIfPresent(HusbandryDO::getMemberId, reqVO.getMemberId())
                .betweenIfPresent(HusbandryDO::getExecuteTime, reqVO.getExecuteTime())
                .eqIfPresent(HusbandryDO::getTake, reqVO.getTake())
                .eqIfPresent(HusbandryDO::getHusbandryImg, reqVO.getHusbandryImg())
                .betweenIfPresent(HusbandryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HusbandryDO::getId));
    }

}
